import {myRequest} from "../../api/myRequest";
import $actions from '../constant/actions'
const _ProcessInstanceManage = 'ProcessInstanceManage';
const ProcessInstance ={
	//******************************实例编辑方法开始*************************************************************************//
	/**
	 * 添加信息
	 * @param record
	 * @returns {Promise<*>}
	 */
	add(record) {
		return myRequest(_ProcessInstanceManage,[{action: $actions.INSTANCE_ADD, data: [record]}]);
	},
	/**
	 * 更新信息
	 * @param record
	 * @returns {Promise<*>}
	 */
	update(record) {
		return myRequest(_ProcessInstanceManage,[{action: $actions.INSTANCE_UPDATE, data: [record]}]);
	},

	/**
	 * 删除信息
	 * @param id
	 * @returns {Promise<*>}
	 */
	delete(filter) {
		return myRequest(_ProcessInstanceManage,[{action: $actions.INSTANCE_DELETE, ...filter}]);
	},
	/**
	 * 按Id删除信息
	 * @param ids
	 * @returns {Promise<*>}
	 */
	deleteById(id) {
		return myRequest(_ProcessInstanceManage,[{action: $actions.INSTANCE_DELETE_BY_ID, id: id}]);
	},

	/**
	 * 批量删除信息
	 * @param ids
	 * @returns {Promise<*>}
	 */
	deleteByIds(ids) {
		return myRequest(_ProcessInstanceManage,[{action: $actions.INSTANCE_DELETE_BY_IDS, ids: ids}]);
	},

	/**
	 * 查询列表
	 * @param filter
	 * @returns {Promise<*>}
	 */
	query(filter) {
		let recipient = [{action: $actions.INSTANCE_QUERY,...filter}]
		return myRequest(_ProcessInstanceManage,recipient);
	},
	/**
	 * 查询列表
	 * @param filter
	 * @returns {Promise<*>}
	 */
	queryIncludeUnpublished(filter) {
		let recipient = [{action: $actions.INSTANCE_QUERY_INCLUDE_UNPUBLISHED,...filter}]
		return myRequest(_ProcessInstanceManage,recipient);
	},
	/**
	 * 分页查询
	 * @param pageNumber
	 * @param pageSize
	 * @param filter
	 * @returns {Promise<unknown | void>}
	 */
	queryByPage(pageNumber, pageSize, filter) {
		let recipient = [{action: $actions.INSTANCE_QUERY_BY_PAGE, pageNumber: pageNumber, pageSize: pageSize,...filter}]
		return myRequest(_ProcessInstanceManage,recipient);
	},

	//******************************实例摘要方法开始*************************************************************************//
	/**
	 * 简单查询不包括实例属性或大字段信息
	 * @param filter
	 * @returns {Promise<*>}
	 */
	queryInfo(filter) {
		let recipient = [{action: $actions.INSTANCE_QUERY_INFO,...filter}]
		return myRequest(_ProcessInstanceManage,recipient);
	},

	/**
	 * 简单查询不包括实例属性或大字段信息
	 * @param filter
	 * @returns {Promise<*>}
	 */
	queryInfoIncludeUnpublished(filter) {
		let recipient = [{action: $actions.INSTANCE_QUERY_INFO_INCLUDE_UNPUBLISHED,...filter}]
		return myRequest(_ProcessInstanceManage,recipient);
	},

	/**
	 * 查询列表
	 * @param recipient
	 * @returns {Promise<*>}
	 */
	queryInfoByPage(pageNumber, pageSize, filter) {
		let recipient = [{action: $actions.INSTANCE_QUERY_INFO_BY_PAGE, pageNumber: pageNumber, pageSize: pageSize,...filter}]
		return myRequest(_ProcessInstanceManage,recipient);
	},
	//******************************实例订阅方法开始*************************************************************************//

}

export default ProcessInstance;
